var t, e = require("../../../../@babel/runtime/helpers/interopRequireDefault"), a = require("../../../../@babel/runtime/helpers/defineProperty"), s = e(require("../../../../@babel/runtime/regenerator")), i = require("../../../../@babel/runtime/helpers/asyncToGenerator"), o = e(require("../../../../dist/toast/toast")), d = getApp(), r = require("../../../../mybehaviors/location/location");

Page({
    behaviors: [ r ],
    data: {
        clicktag: 0,
        language: "",
        options: {},
        _root_tag: "",
        TAG_ACTION_BUY: "-2",
        _goodsId: "",
        _optionsId: "",
        _total: 1,
        currentAddId: "",
        currentAddress: {},
        selectedMode: 0,
        selected: 0,
        dispatch: [],
        popupSpecs: !1,
        addressData: [],
        defaultAddress: {},
        realname: "",
        mobile: "",
        address: "",
        order_data: "",
        dispatch_price: 0,
        goods_price: 0,
        price: 0,
        discount_price: 0,
        deduction_price: 0,
        goodsInfo: {},
        checkDeductionList: [],
        form: {
            username: "",
            mobile: "",
            province: "",
            city: "",
            district: "",
            street: "",
            address: "",
            isDefault: !1
        },
        addressName: "",
        districtVal: "",
        popAddAddress: !1,
        strShow: !1,
        openDateLw: !1,
        provinceData: [],
        cityData: [],
        districtData: [],
        pickerValue: [ 0, 0, 0 ],
        selectAddressData: [],
        streetShow: !1,
        note: {},
        submit_active: !0,
        total_items: [],
        discount_amount_items: [],
        goodsId: "",
        point: {
            lat: "",
            lng: ""
        },
        city: "",
        defaultSelfCarry: {},
        orders_goods: {},
        integral: "",
        is_region: 0,
        TemplateArray: [],
        orderLocationObj: {
            positioning_success: 0,
            province: "",
            city: ""
        },
        getDispatch: !1,
        is_selected: ""
    },
    onLoad: (t = i(s.default.mark(function t(e) {
        var a, i, o, r;
        return s.default.wrap(function(t) {
            for (;;) switch (t.prev = t.next) {
              case 0:
                return t.next = 2, this.checkAlbum("scope.userLocation");

              case 2:
                if (a = t.sent, console.log("userLocationFlag", a), a) {
                    t.next = 6;
                    break;
                }
                return t.abrupt("return", d.tips("获取位置失败，请重新进入后授权"));

              case 6:
                e.is_selected && this.setData({
                    selected: e.is_selected,
                    is_selected: e.is_selected
                });
                try {
                    (i = wx.getStorageSync("integral")) && this.setData({
                        integral: i
                    });
                } catch (t) {}
                this.getCurrentOrderLocation(), this.setData({
                    options: e,
                    _root_tag: e.tag
                }), e.changeSelfCarry && (o = JSON.parse(e.changeSelfCarry), this.setData({
                    defaultSelfCarry: o
                })), this.data._root_tag == this.data.TAG_ACTION_BUY && (this.setData({
                    _goodsId: e.goodsId,
                    _optionsId: e.optionsId,
                    _total: e.total
                }), this._getDataActionBuy()), this._initAddressInfo(), (r = wx.getStorageSync("selfCarryInfo")) && (r = JSON.parse(r), 
                this.setData({
                    "linkinfo.name": r.distributionUserName || "",
                    "linkinfo.mobile": r.distributionUserMobile || ""
                }));

              case 15:
              case "end":
                return t.stop();
            }
        }, t, this);
    })), function(e) {
        return t.apply(this, arguments);
    }),
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {
        this.data.submit_active = !0;
    },
    goLocation_ro: function(t) {
        var e = this.data.form, a = this.data._root_tag, s = this.data.store_id, i = this.data.create;
        wx.navigateTo({
            url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=" + a + "&store_id=" + s + "&form=" + JSON.stringify(e) + "&create=" + i
        });
    },
    gotochangeSelfCarry: function() {
        var t = {
            distributionUserName: this.data.linkinfo.name ? this.data.linkinfo.name : "",
            distributionUserMobile: this.data.linkinfo.mobile ? this.data.linkinfo.mobile : ""
        };
        try {
            wx.setStorageSync("selfCarryInfo", JSON.stringify(t));
        } catch (t) {
            console.log(t);
        }
        wx.navigateTo({
            url: "/packageC/selfCarry/selfCarry_info/selfCarry_info?tag=" + this.data.options.tag + "&goodsId=" + this.data.options.goodsId + "&optionsId=" + this.data.options.optionsId + "&total=" + this.data.options.total + "&iscloud=cloud&goods=" + JSON.stringify(this._assembleGoods())
        });
    },
    setDispatch: function(t) {
        var e = this, a = t.detail.title;
        this.data.dispatch.forEach(function(t) {
            t.name == a && e.setData({
                selected: t.dispatch_type_id,
                selectedMode: "1" == t.dispatch_type_id ? 0 : 1
            });
        }), this._requestByAddress();
    },
    showAddress: function() {
        this._getAddress();
    },
    _getAddress: function() {
        this.addressData = [];
        var t = this, e = d.getNetAddresss("member.member-address.index");
        d._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                if (1 == a.result) {
                    var s = a.data;
                    s = a.data.filter(function(t) {
                        return 1 === t.isdefault;
                    }), t.setData({
                        popupSpecs: !0,
                        addressData: a.data,
                        defaultAddress: s
                    });
                } else (0, o.default)(a.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _setAddressViewData: function(t) {
        null != t && "" != t && t != [] && (this.data.currentAddId = t.id, this.data.currentAddress = t, 
        this.setData({
            realname: d._isTextEmpty(t.username) ? "" : t.username,
            mobile: d._isTextEmpty(t.mobile) ? "" : t.mobile,
            address: d._isTextEmpty(t.province) ? "" : t.province + " " + t.city + " " + t.district + " " + (d._isTextEmpty(t.street) ? "" : t.street + " ") + t.address
        }));
    },
    isOrderAddress_M: function(t) {
        for (var e = 0; e < t.length; e++) if (!t[e].need_address) return console.log("有订单需要填写地址"), 
        !1;
        return !0;
    },
    _setViewData: function(t) {
        var e = this;
        console.log("走了_setViewData设置界面方法");
        var a = this.isOrderAddress_M(t.orders);
        this.setData({
            dispatch: [ {
                name: "快递",
                dispatch_type_id: "1"
            }, {
                name: "上门自提",
                dispatch_type_id: "8"
            } ],
            selected: this.data.selected,
            selectedMode: "1" == this.data.selected ? 0 : 1,
            order_data: t.orders,
            show_address: a,
            price: t.total_price,
            total_items: t.amount_items,
            discount_amount_items: t.discount_amount_items,
            none_loc: !0,
            clicktag: 0
        }), this.data.dispatch.forEach(function(t) {
            8 == t.dispatch_type_id && (console.log("有自提点配送方式，请求定位获取自提点列表"), e._getLocation(function() {
                e.getList();
            }));
        });
    },
    infonamebtn: function(t) {
        var e = t.detail;
        this.setData({
            "linkinfo.name": e
        });
    },
    infonameclear: function() {
        this.setData({
            "linkinfo.name": ""
        });
    },
    infomobileclear: function() {
        this.setData({
            "linkinfo.mobile": ""
        });
    },
    infomobilebtn: function(t) {
        var e = t.detail;
        this.setData({
            "linkinfo.mobile": e
        });
    },
    addresclosebtn: function() {
        this.setData({
            popupSpecs: !1
        });
    },
    selectAddress: function(t) {
        var e = t.currentTarget.dataset.addr;
        this._setAddressViewData(e), this._requestByAddress(), this.setData({
            popupSpecs: !1
        });
    },
    _requestByAddress: function() {
        this.setData({
            order_data: ""
        }), this._getDataActionBuy();
    },
    editAddress: function(t) {
        var e = t.currentTarget.dataset.item;
        this.setData({
            "form.address_id": this.data.defaultAddress[0].id,
            "form.username": this.data.defaultAddress[0].username,
            "form.mobile": this.data.defaultAddress[0].mobile,
            "form.province": this.data.defaultAddress[0].province,
            "form.city": this.data.defaultAddress[0].city,
            "form.district": this.data.defaultAddress[0].district,
            "form.address": this.data.defaultAddress[0].address,
            "form.street": this.data.defaultAddress[0].street,
            "form.isDefault": 0 !== this.data.defaultAddress[0].isDefault,
            "is_point.lng": e.longitude,
            "is_point.lat": e.latitude
        }), this.setData({
            popupSpecs: !1,
            create: !1,
            popAddAddress: !0
        }), this._getStreet(this.data.defaultAddress[0].district_id), this.setData({
            addressName: this.data.form.province + " " + this.data.form.city + " " + this.data.form.district
        });
    },
    popAddressClose: function() {
        this.setData({
            popAddAddress: !1
        });
    },
    usernameinp: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.username": e
        });
    },
    mobileinp: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.mobile": e
        });
    },
    isDefaultChange: function(t) {
        var e = t.detail;
        this.setData({
            "form.isDefault": e
        });
    },
    addressinp: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.address": e
        });
    },
    _closeDateLw: function() {
        this.setData({
            openDateLw: !1
        });
    },
    _initAddressInfo: function() {
        var t = this;
        wx.getStorage({
            key: "provinceData",
            success: function(e) {
                console.log("地址信息准备就绪"), t._getProvinceData();
            },
            fail: function(e) {
                console.log("省fail"), d._getNetWork({
                    url: d.getNetAddresss("member.member-address.address"),
                    success: function(e) {
                        var a = e.data, s = a.data.province, i = a.data.city, o = a.data.district;
                        wx.setStorage({
                            key: "provinceData",
                            data: s
                        }), wx.setStorage({
                            key: "cityData",
                            data: i
                        }), wx.setStorage({
                            key: "districtData",
                            data: o
                        }), t._initAddressInfo();
                    },
                    fail: function(t) {},
                    state: !0
                });
            }
        });
    },
    _getProvinceData: function() {
        var t = this;
        wx.getStorage({
            key: "provinceData",
            success: function(e) {
                t.setData({
                    provinceData: e.data
                }), t.setData({
                    "selectAddressData[0].name": e.data[t.data.pickerValue[0]].areaname,
                    "selectAddressData[0].id": e.data[t.data.pickerValue[0]].id,
                    "selectAddressData[0].index": t.data.pickerValue[0]
                }), t._getCityData();
            }
        });
    },
    _getCityData: function() {
        var t = this.data.selectAddressData[0], e = this;
        wx.getStorage({
            key: "cityData",
            success: function(a) {
                for (var s = [], i = 0; i < a.data.length; i++) a.data[i].parentid == t.id && s.push(a.data[i]);
                e.setData({
                    cityData: s
                }), e.setData({
                    "selectAddressData[1].name": s[e.data.pickerValue[1]].areaname,
                    "selectAddressData[1].id": s[e.data.pickerValue[1]].id,
                    "selectAddressData[1].index": e.data.pickerValue[1]
                }), e._getDistrictData();
            }
        });
    },
    _getDistrictData: function() {
        var t = this.data.selectAddressData[1], e = this;
        wx.getStorage({
            key: "districtData",
            success: function(a) {
                console.log("地区读取成功");
                for (var s = [], i = 0; i < a.data.length; i++) a.data[i].parentid == t.id && s.push(a.data[i]);
                e.setData({
                    districtData: s
                }), e.setData({
                    "selectAddressData[2].name": s[e.data.pickerValue[2]].areaname,
                    "selectAddressData[2].id": s[e.data.pickerValue[2]].id,
                    "selectAddressData[2].index": e.data.pickerValue[2]
                });
            }
        });
    },
    openDateLwtbtn: function() {
        this.setData({
            openDateLw: !0
        });
    },
    bindChange: function(t) {
        var e = t.detail.value;
        this.data.pickerValue[0] != e[0] && (e[1] = 0, e[2] = 0), this.data.pickerValue[1] != e[1] && (e[2] = 0), 
        this.setData({
            "pickerValue[0]": e[0],
            "pickerValue[1]": e[1],
            "pickerValue[2]": e[2]
        }), this._initAddressInfo();
    },
    _okAddress: function() {
        var t = this.data.selectAddressData;
        this.setData({
            "form.street": "",
            districtVal: "",
            addressName: t[0].name + " " + t[1].name + " " + t[2].name,
            "form.province": t[0].name,
            "form.city": t[1].name,
            "form.district": t[2].name
        }), this._getStreet(t[2].id), this._closeDateLw();
    },
    _getStreet: function(t) {
        var e = this, a = d.getNetAddresss("member.memberAddress.street");
        a += "&district_id=" + t, d._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 != a.result || d._isTextEmpty(a.data) ? e.setData({
                    strShow: !1
                }) : !d._isTextEmpty(a.data) && a.data.length > 0 ? e.setData({
                    districtVal: a.data,
                    strShow: !0
                }) : e.setData({
                    strShow: !1
                });
            },
            fail: function(t) {
                e.setData({
                    strShow: !1
                }), console.log(t);
            }
        });
    },
    streetChoose: function() {
        1 == this.data.is_region && d._isTextEmpty(this.data.addressName) ? wx.showToast({
            icon: "none",
            title: "请先选择所在地区",
            duration: 1500
        }) : this.setData({
            streetShow: !0
        });
    },
    streetClose: function() {
        this.setData({
            streetShow: !1
        });
    },
    streetConfirm: function(t) {
        var e = t.target.dataset.strname;
        this.setData({
            "form.street": e,
            streetShow: !1
        });
    },
    appendAddress: function(t) {
        var e = this, a = t.currentTarget.dataset.apptype;
        if (d._isTextEmpty(this.data.form.username)) wx.showToast({
            icon: "none",
            title: "请输入收货人姓名",
            duration: 1500
        }); else if (d._isTextEmpty(this.data.form.mobile)) wx.showToast({
            icon: "none",
            title: "请输入联系电话",
            duration: 1500
        }); else if (/^[0-9]{1,}$/.test(this.data.form.mobile)) if (1 == this.data.is_region && d._isTextEmpty(this.data.addressName)) wx.showToast({
            icon: "none",
            title: "请选择所在区域",
            duration: 1500
        }); else if (1 == this.data.is_region && this.data.strShow && d._isTextEmpty(this.data.form.street)) wx.showToast({
            icon: "none",
            title: "请选择所在街道",
            duration: 1500
        }); else if (d._isTextEmpty(this.data.form.address)) wx.showToast({
            icon: "none",
            title: "请输入详细地址",
            duration: 1500
        }); else {
            var s = {
                username: this.data.form.username,
                mobile: this.data.form.mobile,
                province: this.data.form.province,
                city: this.data.form.city,
                district: this.data.form.district,
                address: this.data.form.address,
                isdefault: this.data.form.isDefault ? 1 : 0,
                address_id: this.data.form.address_id
            };
            this.data.is_point && (s.longitude = this.data.is_point.lng, s.latitude = this.data.is_point.lat), 
            this.data.strShow && (s.street = this.data.form.street);
            var i = "";
            i = "update" === a ? d.getNetAddresss("member.member-address.update") : d.getNetAddresss("member.member-address.store"), 
            d._postNetWork({
                url: i,
                showToastIn: !1,
                data: s,
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? ((0, o.default)(a.msg), e.popAddressClose(), e._setAddressViewData(a.data), 
                    e._requestByAddress(), e.setData({
                        "form.username": "",
                        "form.mobile": "",
                        "form.province": "",
                        "form.city": "",
                        "form.district": "",
                        "form.street": "",
                        "form.address": "",
                        "form.isDefault": !1,
                        addressName: ""
                    })) : (0, o.default)(a.msg);
                },
                fail: function(t) {}
            });
        } else wx.showToast({
            icon: "none",
            title: "请输入联系电话",
            duration: 1500
        });
    },
    addAddress: function() {
        this.getIsOpenAddress(), this.setData({
            popupSpecs: !1
        }), console.log(this.data.delivery_status, this.data.selected), this.showAddAddress();
    },
    getIsOpenAddress: function() {
        var t = this, e = d.getNetAddresss("member.member-address.is-region");
        d._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 != a.result || d._isTextEmpty(a.data) ? console.log(a.msg) : t.setData({
                    is_region: a.data.is_region
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showAddAddress: function() {
        this.setData({
            "form.username": "",
            "form.mobile": "",
            "form.province": "",
            "form.city": "",
            "form.district": "",
            "form.street": "",
            "form.address": "",
            "form.isDefault": !1,
            addressName: "",
            popAddAddress: !0,
            create: !0
        });
    },
    noteHandle: function(t) {
        var e = this, s = t.target.dataset.preid, i = t.target.dataset.item, o = t.detail.value;
        if (this.setData(a({}, "note." + s, o)), i.order_deductions[0]) this._screenDiscount(i, i.order_deductions[0]); else {
            var d = !1;
            this.data.checkDeductionList.length > 0 && (this.data.checkDeductionList = this.data.checkDeductionList.map(function(t, a) {
                t.pre_id == i.pre_id && (d = !0, t.note = e.data.note[i.pre_id]);
            })), d || this.data.checkDeductionList.push({
                deduction_ids: [],
                pre_id: i.pre_id,
                note: this.data.note[i.pre_id]
            }), this.setData({
                checkDeductionList: this.data.checkDeductionList
            });
        }
    },
    _screenDiscount: function(t, e) {
        var a = this;
        this.data.checkDeductionList.length > 0 ? this.data.checkDeductionList = this.data.checkDeductionList.map(function(s, i) {
            s.pre_id == t.pre_id && (e.checked ? s.deduction_ids && -1 == s.deduction_ids.indexOf(e.code) && s.deduction_ids.push(e.code) : s.deduction_ids && s.deduction_ids.indexOf(e.code) > -1 && s.deduction_ids.splice(s.deduction_ids.indexOf(e.code), 1), 
            s.note = a.data.note[t.pre_id], s.service_fee = a.data.service_fee[t.pre_id]);
        }) : this.data.checkDeductionList.push({
            deduction_ids: [ e.code ],
            pre_id: t.pre_id,
            note: this.data.note[t.pre_id],
            service_fee: this.data.service_fee[t.pre_id]
        }), this.setData({
            checkDeductionList: this.data.checkDeductionList
        });
    },
    _getDataActionBuy: function() {
        var t = this, e = "";
        e = d.getNetAddresss("plugin.cloud-warehouse.frontend.goods-buy.index"), e += "&goods_id=" + this.data._goodsId, 
        e += "&total=" + this.data._total, e += "&option_id=" + this.data._optionsId, e += "&member_coupon_ids=" + [], 
        e += "&orders=" + JSON.stringify([]), e += "&address=" + encodeURIComponent(JSON.stringify(this.data.currentAddress)), 
        e += "&dispatch_type_id=" + this.data.selected, 8 == this.data.selected && (e += "&package_deliver_id=" + this.data.defaultSelfCarry.id), 
        e += "&mark=" + (this.data.options.mark ? this.data.options.mark : 0), 0 == this.data.clicktag && (this.setData({
            clicktag: 1
        }), d._getNetWork({
            url: e,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (t.setData({
                    goodsInfo: a.data,
                    cup_notice: !0
                }), t._setViewData(a.data), t._setAddressViewData(a.data.dispatch.default_member_address)) : (t.setData({
                    cup_notice: !0
                }), (0, o.default)(a.msg)), setTimeout(function() {
                    t.setData({
                        clicktag: 0
                    });
                }, 1e3);
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    },
    getTemplate: function() {
        var t = d.getNetAddresss("member.member.getMiniTemplateCorrespond"), e = this;
        d._getNetWork({
            url: t,
            data: {
                small_type: 1
            },
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    for (var s = [], i = 0; i < a.data.length; i++) s.push(a.data[i].template_id);
                    e.setData({
                        TemplateArray: s
                    }), wx.requestSubscribeMessage({
                        tmplIds: e.data.TemplateArray,
                        success: function(t) {
                            console.log(t, "success"), e.submitBtn();
                        },
                        fail: function(t) {
                            console.log(t, "err"), e.submitBtn();
                        }
                    });
                } else (0, o.default)(a.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    submit: function() {
        this.getTemplate();
    },
    submitBtn: function() {
        var t = this;
        if (1 == this.data.submit_active) {
            if (this.data.submit_active = !1, 8 == this.data.selected) {
                if (d._isTextEmpty(this.data.defaultSelfCarry.id)) return wx.showModal({
                    title: "提示",
                    content: "请选择自提点",
                    showCancel: !1,
                    confirmText: "确定",
                    confirmColor: "#000000",
                    success: function(t) {},
                    fail: function(t) {},
                    complete: function(t) {}
                }), void (this.data.submit_active = !0);
                if (d._isTextEmpty(this.data.linkinfo.name)) return wx.showModal({
                    title: "提示",
                    content: "请填写提货人姓名",
                    showCancel: !1,
                    confirmText: "确定",
                    confirmColor: "#000000",
                    success: function(t) {}
                }), void (this.data.submit_active = !0);
                if (d._isTextEmpty(this.data.linkinfo.mobile)) return wx.showModal({
                    title: "提示",
                    content: "请输入提货人手机",
                    showCancel: !1,
                    confirmText: "确定",
                    confirmColor: "#000000",
                    success: function(t) {}
                }), void (this.data.submit_active = !0);
                var e = {
                    distributionUserName: this.data.linkinfo.name ? this.data.linkinfo.name : "",
                    distributionUserMobile: this.data.linkinfo.mobile ? this.data.linkinfo.mobile : ""
                };
                try {
                    wx.setStorageSync("selfCarryInfo", JSON.stringify(e));
                } catch (t) {
                    console.log(t);
                }
            }
            if (!this.isOrderAddress_M(this.data.order_data) && (1 == this.data.selected || 3 == this.data.selected) && d._isTextEmpty(this.data.currentAddId)) return wx.showModal({
                title: "提示",
                content: "请选择收货地址",
                showCancel: !1,
                confirmText: "确定",
                confirmColor: "#000000",
                success: function(e) {
                    t.showAddress();
                },
                fail: function(t) {}
            }), void (this.data.submit_active = !0);
            var a, s = this, i = this._assembleJson();
            a = d.getNetAddresss("plugin.cloud-warehouse.frontend.create.index"), 0 == this.data.clicktag && (this.setData({
                clicktag: 1
            }), d._postNetWork({
                url: a,
                showToastIn: !1,
                data: i,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? wx.showToast({
                        title: "下单成功",
                        icon: "none",
                        duration: 1e3,
                        success: function() {
                            setTimeout(function() {
                                wx.navigateBack({
                                    delta: 2
                                });
                            }, 900);
                        }
                    }) : (0, o.default)(e.msg), setTimeout(function() {
                        s.setData({
                            clicktag: 0
                        });
                    }, 1e3);
                },
                fail: function(t) {
                    console.log(t);
                }
            }));
        }
    },
    _assembleGoods: function() {
        for (var t = [], e = 0; e < this.data.goodsInfo.orders.length; e++) for (var a = 0; a < this.data.goodsInfo.orders[e].order_goods.length; a++) {
            var s = {};
            s.goods_id = this.data.goodsInfo.orders[e].order_goods[a].goods_id, s.total = this.data.goodsInfo.orders[e].order_goods[a].total, 
            s.option_id = this.data.goodsInfo.orders[e].order_goods[a].goods_option_id, t.push(s);
        }
        return t;
    },
    _assembleJson: function() {
        var t = {};
        return this.data._root_tag == this.data.TAG_ACTION_BUY && (t = {
            dispatch_type_id: this.data.selected,
            address: encodeURIComponent(JSON.stringify(this.data.currentAddress)),
            goods: JSON.stringify(this._assembleGoods()),
            member_coupon_ids: JSON.stringify([]),
            orders: JSON.stringify([]),
            mark: this.data.options.mark ? this.data.options.mark : 0,
            invoice_type: this.data.iscur_c ? 0 : 1,
            rise_type: this.data.iscur ? 1 : 0,
            call: this.data.invoice_list.call,
            email: this.data.invoice_list.email,
            company_number: this.data.invoice_list.company_number
        }), 8 == this.data.selected && (t.dispatch_type_id = this.data.selected, t.package_deliver_id = this.data.defaultSelfCarry.id, 
        t.realname = this.data.linkinfo.name, t.mobile = this.data.linkinfo.mobile, delete t.address), 
        Object.assign(t, this.data.orderLocationObj), t;
    },
    getList: function() {
        var t = this, e = d.getNetAddresss("plugin.package-deliver.frontend.deliver.getList"), a = d.qqMapTransBMap(parseFloat(t.data.point.lng), parseFloat(t.data.point.lat));
        d._getNetWork({
            url: e,
            data: {
                city_name: t.data.city,
                lat: a.lat,
                lng: a.lng,
                kwd: "",
                goods: JSON.stringify(this._assembleGoods())
            },
            success: function(e) {
                var a = e.data;
                1 == a.result ? t.setData({
                    defaultSelfCarry: "{}" == JSON.stringify(t.data.defaultSelfCarry) ? a.data.list.data[0] : t.data.defaultSelfCarry
                }) : wx.showToast({
                    icon: "none",
                    title: "获取自提点失败",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getCurrentOrderLocation: function() {
        var t = this;
        wx.getLocation({
            type: "gcj02",
            success: function(e) {
                console.log("userLocationFlag", e);
                var a = e.latitude, s = e.longitude;
                t._setOrderLocation({
                    lat: a,
                    lng: s
                });
            }
        });
    },
    _setOrderLocation: function(t) {
        var e = this;
        d.getReverseGeocoder(t.lat, t.lng).then(function(t) {
            console.log("userLocationFlag", t);
            var a = t.address_component, s = {
                positioning_success: 1,
                province: a.province,
                city: d._isTextEmpty(a.city) ? a.province : a.city
            };
            e.data.orderLocationObj = s;
        }).catch(function(t) {
            console.log(t);
        });
    },
    checkAlbum: function(t) {
        var e = this;
        return new Promise(function() {
            var a = i(s.default.mark(function a(i, o) {
                return s.default.wrap(function(a) {
                    for (;;) switch (a.prev = a.next) {
                      case 0:
                        return a.next = 2, e.getAuthSetting(t);

                      case 2:
                        a.sent ? i(!0) : wx.showModal({
                            title: "请开启授权",
                            content: "是否跳转设置页开启授权",
                            success: function(e) {
                                e.confirm ? wx.openSetting({
                                    success: function(e) {
                                        e.authSetting[t] ? i(!0) : i(!1);
                                    }
                                }) : e.cancel && i(!1);
                            },
                            fail: function() {
                                i(!1);
                            }
                        });

                      case 4:
                      case "end":
                        return a.stop();
                    }
                }, a);
            }));
            return function(t, e) {
                return a.apply(this, arguments);
            };
        }());
    },
    getAuthSetting: function(t) {
        return new Promise(function(e, a) {
            wx.getSetting({
                success: function(a) {
                    a.authSetting[t] ? e(!0) : wx.authorize({
                        scope: t,
                        success: function() {
                            e(!0);
                        },
                        fail: function() {
                            e(!1);
                        }
                    });
                },
                fail: function() {
                    e(!1);
                }
            });
        });
    }
});